package com.ls.io.rpc.protobuf;

import java.nio.ByteBuffer;

public class RpcHeader {
    /**
     *  标志位
     */
    private int flag;

    /**
     * 请求id
     */
    private long requestId;

    /**
     * 消息长度
     */
    private long length;


    public byte[] toArray(){
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(20);
        byteBuffer.putInt(flag);
        byteBuffer.putLong(requestId);
        byteBuffer.putLong(length);

        byte[] bytes = new byte[20];
        byteBuffer.flip();
        byteBuffer.get(bytes);
        return bytes;
    }

    public int getFlag() {
        return flag;
    }

    public void setFlag(int flag) {
        this.flag = flag;
    }

    public long getRequestId() {
        return requestId;
    }

    public void setRequestId(long requestId) {
        this.requestId = requestId;
    }

    public long getLength() {
        return length;
    }

    public void setLength(long length) {
        this.length = length;
    }
}
